from selenium import  webdriver

from selenium.webdriver.common.by import  By
service=webdriver.ChromeService()
service.path='./chromedriver-win64/chromedriver.exe'
options=webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
browser = webdriver.Chrome(service=service, options=options)
browser.get("https://www.baidu.com")

# #根据id来找到对象
# button = browser.find_element(by=By.ID, value='su')
# print(button)
#
# #根据标签属性的属性值来获取对象
#
# button=browser.find_element(by=By.NAME,value='wd')
# print(button)
#
# #根据xpath语句来获取列表
# button = browser.find_elements(by=By.XPATH, value='//input[@id="su"]')
# print(button)

#根据标签的名字来获取对象
# input = browser.find_element(by=By.TAG_NAME, value='input')
# print(input)

#使用bs4的语法来获取对象
button = browser.find_element(by=By.CSS_SELECTOR, value='#su')
print(button)
 #获取链接文本
print(button)
